import Vue from 'vue'
import Router from 'vue-router'
import Home from '../page/Home.vue'
import PlayVideo from '../page/PlayVideo.vue'
import Contribute from '../page/Contribute.vue'
import LoginIn from '../page/LoginIn.vue'
import SignUp from '../page/SignUp.vue'
import Search from '../page/Search.vue'

Vue.use(Router)

const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    {
      path:'/home',
      name:'home',
      component:Home
    },
    {
      path:'/playVideo',
      name:'playVideo',
      component:PlayVideo
    },
    {
      path:'/contribute',
      name:'contribute',
      component:Contribute
    },
    {
      path:'/loginIn',
      name:'loginIn',
      component:LoginIn
    },
    {
      path:'/signUp',
      name:'signUp',
      component:SignUp
    },
    {
      path:'/search',
      name:'search',
      component:Search
    },
    {
      path: '/',
      redirect: '/home'
    }
  ]
})
